package com.project.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Title: LoginInterceptor
 * @Package: com.project.interceptor
 * @Description:
 * @Author: Liang-Xie
 * @Date: 2022/6/29 - 14:02
 */
@SuppressWarnings("all")
public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object obj=request.getSession().getAttribute("loginUser");
        if (obj==null){
            response.sendRedirect("/login.html?errorInfo=noland");
            return false;
        }
        return true;
    }
}
